import { hyRequest } from '@/service'
import type { selectArr, agentListParams } from '@/service/common/type'
import { result } from '@/service/type'

const agentUrl: string[] = [
  '/asm/rate/basePolicy/selectAgentList',
  '/asm/rate/cabinPolicy/selectByPolicyId'
]
export const $select = {
  select: () => {
    return hyRequest.get<result<selectArr[]>>({
      url: '/asm/agent/data/select'
    })
  },
  selectAgentList: (data: agentListParams) =>
    hyRequest.get<result>({
      url: agentUrl[data.agentUrlIndex],
      params: {
        policyId: data.policyId,
        size: data.size,
        page: data.page
      }
    }),
  selectByAirline: () =>
    hyRequest.get<result>({
      url: '/asm/airlineAgent/data/selectByAirline'
    })
}

export const $login = {
  getCaptcha: () =>
    hyRequest.get({
      url: '/asm/getCaptcha',
      responseType: 'arraybuffer'
    }),
  loginOk: (data: any) =>
    hyRequest.post<result>({
      url: '/asm/login',
      data
    }),
  getMenu: () =>
    hyRequest.get<result>({
      url: '/asm/api/menu.info'
    })
}
